extends Node2D


# Declare member variables here. Examples:
# var a = 2
# var b = "text"
export var has_Food=true
var first_tip=true
#当模式是教学模式的时候，发送信号，隐藏敌人，并不让他移动
signal in_teach
# Called when the node enters the scene tree for the first time.
func _ready():
	get_tree().debug_collisions_hint=true
	var file=File.new()
	file.open("user://gameData.json",File.READ_WRITE)
	if file.file_exists("user://gameData.json"):
		pass
	else:
	#	开始新手教程 当状态为空时，从头开始之前教程
		if Global.tip_action=="":
			emit_signal("in_teach")
			$newer_tip.start_teach()
			pass
		if Global.tip_action=="去喝水":
			Global.tip_action="喝水"
		if Global.tip_action=="喝水":
			$newer_tip/tip_anim.play("Drink")
		print("当前教程状态>",Global.tip_action)
	pass
func _on_Area2D_body_entered(body):
	if body.name=="kine":
		get_tree().change_scene("res://Scenes/Levelketing.tscn")
	pass # Replace with function body.
# warning-ignore:unused_argument
func _process(delta):
	if Global.tip_action=="去繁殖":
		$newer_tip/tip_anim.play("to_Fanzhi")
		set_process(false)
	pass
#继续游戏 取消暂停
func continue_game():
	get_tree().paused=false
	print("恢复游戏运行")
#观看新手教程
func _on_yes_pressed():
	$newer_tip.text="天大地大吃饭最大，对于蟑螂来说也是这样的，请移动至客厅寻找食物"
	$newer_tip/tip_anim.play("tip_eat")
	pass # Replace with function body.

#不观看新手教程
func _on_no_pressed():
	$newer_tip.text="那也可以，如果想观看新手教程，随时都可以在设置中观看。\n现已允许自由活动"
	$newer_tip/tip_anim.play("dont watch")	
	pass # Replace with function body.


func _on_water_body_entered(body):
	if body.name=="kine":
		Global.canDrink=true
	pass # Replace with function body.


func _on_water_body_exited(body):
	if body.name=="kine":
		Global.canDrink=false
	pass # Replace with function body.

#彩蛋 死亡
func _on_btn_caidan1_pressed():
	print("你启动了主人家的自爆系统，祝你好运")
	$bgm.stop()
	$warn.play()
	$errorLayer/Label.show()
	$errorLayer/error.show()
	$end_Timer.start()
	pass # Replace with function body.


func _on_end_Timer_timeout():
# warning-ignore:return_value_discarded
	get_tree().change_scene("res://Scenes/Main.tscn")
	pass # Replace with function body.
